package org.proyectosinapsis.Sinapsis.library;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.RelativeLayout;
import android.widget.TextView;
import org.proyectosinapsis.Sinapsis.R;

/**
 * User: Alexander Simoes
 * Company: CoralVision Systems
 * Date: 9/30/12
 */
public class InfoArrayAdapter extends ArrayAdapter<String[]> {
	private final Context context;
	private final String[][] values;
	private final int resource;


	public InfoArrayAdapter(Context context, int layoutID, String[][] values) {
		super(context, layoutID, values);
		this.context = context;
		this.values = values;
		this.resource = layoutID;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		RelativeLayout row;

		if (convertView==null) {
			row = new RelativeLayout(getContext());
			String inflater = Context.LAYOUT_INFLATER_SERVICE;
			LayoutInflater vi;
			vi = (LayoutInflater) getContext().getSystemService(inflater);
			vi.inflate(resource, row, true);
		} else {
			row = (RelativeLayout) convertView;
		}

		/*LayoutInflater inflater = (LayoutInflater) context.
			getSystemService(Context.LAYOUT_INFLATER_SERVICE);

		View rowView = inflater.inflate(R.layout.row, parent, false);*/
		TextView title = (TextView) row.findViewById(R.id.title);
		TextView info = (TextView) row.findViewById(R.id.info);
		title.setText(values[position][0]);
		info.setText(values[position][1]);

		return row;
	}
}
